package com.itzhihao.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itzhihao.entity.Order;
import com.itzhihao.entity.vo.OrderVo;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.page.PageDomain;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface OrderMapper extends BaseMapper<Order> {

    @Log
    @Select("select distinct o.order_id as orderId,o.status,o.assess,o.assess_level as assessLevel,o.num,o.price,o.pay_type as payType,o.is_deleted as isDeleted,s.name as storeName,s.mainimage as storeMainImage," +
            "o.complete_time as completeTime,p.mainimage as mainImage,p.name,a.pos_name as posName,a.pos_address as posAddress,a.phone,o.create_time as createTime " +
            " from glgl_store as s, glgl_order as o,glgl_product as p,sys_user as u,glgl_address as a where o.user_id = #{userId} and o.address_id = a.address_id and o.store_id = s.store_id and " +
            " o.product_id = p.prod_id and o.status = ifnull(#{order.status},o.status) order by o.create_time desc limit #{pageDomain.pageStart},#{pageDomain.pageSize}")
    List<OrderVo> getListByStatus(@Param(value = "userId") Long userId,@Param(value = "pageDomain") PageDomain pageDomain, @Param(value = "order") Order order);
}
